package mobi.yuanshen.test;

import jakarta.servlet.*;
import jakarta.servlet.annotation.WebFilter;

import java.io.IOException;

//@WebFilter(urlPatterns = "/*")
public class DemoFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        Filter.super.init(filterConfig);
    }

    @Override
    public void doFilter(ServletRequest servletRequest,
                         ServletResponse servletResponse,
                         FilterChain filterChain) throws IOException, ServletException {
        System.out.println("拦截到请求,开始放行");
        filterChain.doFilter(servletRequest,servletResponse); // 放行
        System.out.println("放行结束，回到doFilter方法");
    }

    @Override
    public void destroy() {
        Filter.super.destroy();
    }
}
